package com.qingke.memo.command.system;

import com.qingke.memo.command.SystemCommand;
import com.qingke.memo.pojo.CustomTag;
import com.qingke.memo.unit.MConsole;

public class CreateCustomTag extends SystemCommand {

	@Override
	public void execute() {
		String code=MConsole.promptNotEmpty("code:");
		if(dao.isCustomTagExistByCode(code)){
			MConsole.println("the custom tag code have been existed.");
			return ;
		}
		String name=MConsole.promptNotEmpty("name:");
		String description=MConsole.prompt("description:");
		
		CustomTag customTag=new CustomTag();
		customTag.setCode(code);
		customTag.setName(name);
		customTag.setDescription(description);
		
		
		boolean isSuccess=dao.insertCustomTag(customTag);
		if(isSuccess)
			MConsole.println("create custom tag success.");
		else
			MConsole.println("create custom tag failed.");
	}

}
